package com.myfoon.model.entity;

import com.tangosol.io.ExternalizableLite;

import com.tangosol.util.ExternalizableHelper;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.QueryHint;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;


@Entity
@NamedQueries({@NamedQuery(name = "Country.findAll", 
                           query = "select cn from CountryName cn where cn.language = :language order by cn.name",
                           hints = {
                                    @QueryHint(name = "org.hibernate.cacheable", value = "true"),
                                    @QueryHint(name = "org.hibernate.cacheRegion", value = "Country")
                                   }
                           )
               }
              )
@Cache (usage=CacheConcurrencyStrategy.READ_ONLY)
@Table(name = "COUNTRY")
public class Country implements Serializable {    
    private Integer id;
    private String code;
        
    public Country() {
    }

    public Country(Integer id) {
        this.id = id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }

    @Id 
    @GeneratedValue(generator = "CountrySequence", strategy = GenerationType.AUTO)
    @SequenceGenerator(name = "CountrySequence", allocationSize = 1, sequenceName = "COUNTRY_SEQ_01")
    @Column(name = "ID", unique = true, nullable = false, precision = 10, scale = 0)
    public Integer getId() {
        return id;
    }

    public void setCode(String code) {
        this.code = code;
    }
    
    @Column(name = "CODE", length = 3, nullable = false)    
    public String getCode() {
        return code;
    }
}
